#define _CRT_SECURE_NO_WARNINGS 1
#include "string.h"

namespace YZW
{
	void test_00() {
		/*const string s1;
		string s2("abcdefghijklmn");

		cout << s1.c_str() << " " << s2.c_str() << endl;

		for (int i = 0; i < s2.size(); i++)
		{
			cout << s2[i] << " ";
		}

		cout << endl;

		string::iterator it = s2.begin();
		while (it != s2.end())
		{
			cout << *it << " ";
			it++;
		}
		cout << endl;
		for (auto it : s2)
		{
			cout << it << " ";
		}*/

		string s1("hello string");

		s1.pushback('!');
		s1 += '!';
		s1.append("  wareing");
		s1 += '@';
		/*for (auto e : s1)
		{
			cout << e << endl;
		}*/

		auto it = s1.begin();
		while (it != s1.end())
		{
			cout << *it << " ";
			it++;
		}
		cout << endl;
		cout << s1.c_str();

		string s2;
		s2 += "hello Yzw";
		cout << s2.c_str() << endl;
	}

	void test02()
	{
		cout << endl;
		string s1;
		size_t n = s1.size();
		size_t i = 10;
		while (i)
		{
			s1 += "hel";//6
			if (n != s1.size())
			{
				cout << "s1 is malloc" << " " << n << endl;;
				n = s1.size();
			}
			i--;
		}
	}

	void test01()
	{
		string s1;
		s1.append("hello");
		s1 += " bit";
		cout << s1.c_str() << endl;
		cout << s1.size() << " " << s1.capacity();

		string s2;
		s2 += "hell yzw";
		s2.insert(0, 'o');
		cout << endl << s2.c_str();
		//test02();
	}

	void test_insert()
	{
		string s1;
		s1.append("hello C++");

		s1.insert(0, 'I');

		cout << s1.c_str();
	}

	void test()
	{
		test_insert();
	}
}

//int main()
//{
//	//YZW::test01();
//	YZW::test();
//	return 0;
//}